package addDigits;

public class Solution {
    public static void main(String[] args) {
        System.out.println(fun(10));
    }
    public static int addDigits(int num) {
        while(num>=10){
            num=fun(num);
        }
        return num;
    }
    private static int fun(int n){
        int res=0;
        while(n>0){
            res+= n%10;
            n/=10;
        }
        return res;
    }
}
